home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZUndoIPTask.cpp -- an undo task for Image Processing ops in GWorld windows
- *
- * (provided as an example of how to use it)
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
-
- #include "ZUndoIPTask.h"
- #include "ZGWorld.h"
- #include "ZGWorldWindow.h"
-
-
- ZUndoIPTask::ZUndoIPTask( Str63 taskName, ZWindow* aWindow, short ipTaskID )
- : ZUndoTask( taskName, aWindow )
- {
- taskCode = ipTaskID;
- }
-
-
-
- void ZUndoIPTask::Do()
- {
- ZGWorld* aGW;
- ZGWorldWindow* zW;
-
- zW = (ZGWorldWindow*) itsTarget;
-
- if (zW)
- {
- aGW = zW->GetGWorld();
-
- switch (taskCode)
- {
- case undoInvert:
- aGW->Invert();
- zW->MakePaletteForWindow();
- break;
-
- // you could make this object perform more than one task by extending the
- // range of task codes and implementing more cases here to handle
- // each one. This may be better design than having a separate task object
- // for all possible tasks, since related functions are grouped and code can
- // be shared where this is appropriate.
- default:
- break;
- }
-
- zW->Focus();
- zW->Draw();
- }
-
- inherited::Do(); // important! Call inherited Do to maintain state
- }
-
-
-
- void ZUndoIPTask::Undo()
- {
- // because this task only currently deals with invert, Undo and Do amount to the same
- // thing. This will not normally be the case, but for the sake of a simple illustration,
- // this should be enough to show you how this works. If you extend this to perform other
- // image processing tasks on a GWorld, the Undo will probably need to be more
- // sophisticated- for example you may need to copy the image to another GWorld owned by
- // this task in order to put it back completely when Undo is called.
-
- Do();
- inherited::Undo(); // must call the inherited Undo at the end
- }
-